package upicgame.entity;

import javax.persistence.*;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

@Entity
@Table(name="cartitem")
public class CartItem {
	private Integer id;
	private User user;
	private Game game;
	//判断是否可以结算
	private boolean account;
	public CartItem() {
	
	}
	public CartItem(Integer id) {
		super();
		this.id = id;
	}
	public CartItem(Integer id, User user, Game game) {
		super();
		this.id = id;
		this.user = user;
		this.game = game;
	}
	public CartItem(Integer id, Game game) {
		super();
		this.id = id;
		this.game = game;
	}
	public CartItem(User user, Game game) {
		super();
		this.user = user;
		this.game = game;
	}
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name="user_id")
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}
	
	
	@OneToOne(fetch = FetchType.LAZY)
	@JoinColumn(name="game_id")
//	@Fetch(FetchMode.JOIN)
	public Game getGame() {
		return game;
	}
	public void setGame(Game game) {
		this.game = game;
	}
	
	public boolean isAccount() {
		return account;
	}
	public void setAccount(boolean account) {
		this.account = account;
	}
	@Override
	public String toString() {
		return "CartItem [id=" + id + ", user=" + user + ", game=" + game + ", account=" + account + "]";
	}
	

	

	
	
}
